import 'package:flutter_base/utils/shared/shared_export.dart';
import 'package:shared_preferences/shared_preferences.dart';

class SharedStorage {
  static final SharedStorage _instance = SharedStorage._();

  factory SharedStorage() => _instance;

  SharedStorage._();

  late SharedPreferences prefs;

  Future initShareStorage() async {
    prefs = await SharedPreferences.getInstance();
  }

  //第一次启动
  Future<bool> firstLaunched() {
    return prefs.setBool(SharedKey.firstLaunch, false);
  }
  //是否是第一次启动
  bool isFirstOpen() {
    return prefs.getBool(SharedKey.firstLaunch)??true;
  }

  //第一次启动
  String? getDeviceId() {
    return prefs.getString(SharedKey.deviceId);
  }

  // 设置震动提醒
  Future<void> setShakeRemind(bool value) async {
    await prefs.setBool(SharedKey.shakeRemind, value);
  }

  // 获取震动提醒
  bool getShakeRemind() {
    return prefs.getBool(SharedKey.shakeRemind) ?? true; // 默认开启
  }

  // 设置礼物特效
  Future<void> setGiftSpecial(bool value) async {
    await prefs.setBool(SharedKey.giftSpecial, value);
  }

  // 获取礼物特效
  bool getGiftSpecial() {
    return prefs.getBool(SharedKey.giftSpecial) ?? true; // 默认开启
  }

  // 设置座驾特效
  Future<void> setVehicleSwitch(bool value) async {
    await prefs.setBool(SharedKey.vehicleSwitch, value);
  }

  // 获取座驾特效
  bool getVehicleSwitch() {
    return prefs.getBool(SharedKey.vehicleSwitch) ?? true; // 默认开启
  }
}
